package ge.modules.logics;

import ge.engine.Actor;
import ge.modules.drawables.Color;
import ge.modules.drawables.SquareModule;

 

public class SquareCollide extends GeomCollideFigure {

	//Width
	private double w;
	//Height
	private double h;
	private SquareModule debugDraw;

	/**
	 * 	Construct a new Collision Square
	 * @param width	Width of the square
	 * @param height Height of the square
	 * @param id Identifier 
	 */
	public SquareCollide(double width, double height, int id)
	{
		super(id);
		this.w = width;
		this.h = height;
 
	}

	
	/**
	 * 	Construct a new Square. Identifier will be 0.
	 * @param width	Width of the square
	 * @param height Height of the square
	 */
	public SquareCollide(double width, double height)
	{
		super();
		this.w = width;
		this.h = height;
		
	}
	@Override
	public void setDraw(boolean draw)
	{
		super.setDraw(draw);
		if(this.draw)
		{
			debugDraw = new SquareModule(this.w,this.h);
			debugDraw.setPos(X, Y);
		}
		else
			debugDraw = null;
	}
	@Override
	public void setPos(double x, double y) 
	{
		super.setPos(x, y);
		if(draw)
			debugDraw.setPos(x, y);
	}
	public double getWidth()
	{
		return w;
	}
	public double getHeight() 
	{
		return h;
	}
	@Override
	public void draw() 
	{
		if(!draw)
			return;
		
			if(colision.isCollision())
			{
				if(colision.collideInside())
					debugDraw.setColor(new Color(0,0,255));
				else
					debugDraw.setColor(new Color(0,255,0));
			}
			else
				debugDraw.setColor(new Color(255,0,0));
			
			debugDraw.draw();
	}
	
	
	@Override
	public void update() 
	{
		super.update();
		if(draw)
			debugDraw.update();
		
	}
	@Override
	public void setArea(double width, double height) {
		 w = width;
		 h = height;
	}
	
}
